package com.ibeeking.found.upms.cs.rest.service.impl;

import com.ibeeking.found.upms.cs.rest.service.ICsRolePermissionService;
import com.ibeeking.found.upms.service.common.bo.CsRolePermissionBO;
import com.ibeeking.found.upms.service.common.dos.CsRolePermissionDO;
import com.ibeeking.found.upms.service.mapper.CsRolePermissionMapper;
import com.ibeeking.nematos.utils.data.Collections3;
import com.ibeeking.nematos.utils.json.JsonUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName CsRolePermissionServiceImpl
 * @Description
 * @Author ibeeking
 * @Date 2021-05-13 11:40
 **/
@Service
public class CsRolePermissionServiceImpl implements ICsRolePermissionService {

    @Resource
    private CsRolePermissionMapper csRolePermissionMapper;

    @Override
    public List<CsRolePermissionBO> queryRolePermissionByRoleIds(List<Long> roleIds) {
        List<CsRolePermissionDO> rolePermissionDos = csRolePermissionMapper.selectList(new LambdaQueryWrapper<>(CsRolePermissionDO.class).in(CsRolePermissionDO::getRoleId, roleIds));
        if (Collections3.isEmpty(rolePermissionDos)) {
            return Collections3.emptyList();
        }
        return JsonUtils.jsonToList(rolePermissionDos, CsRolePermissionBO.class);
    }
}
